<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Log;

use Hyperf\Logger\LoggerFactory;
use Hyperf\Utils\ApplicationContext;

/**
 * @method static void info( string $message , array $context = [])
 * @method static void emergency( string $message , array $context = [] )
 * @method static void alert( string $message , array $context = [] )
 * @method static void critical( string $message , array $context = [] )
 * @method static void error( string $message , array $context = [] )
 * @method static void warning( string $message , array $context = [])
 * @method static void notice( string $message , array $context = [])
 * @method static void debug( string $message , array $context = [] )
 * @method static void log( $level , string $message , array $context = [] )
 */
class WsLog
{
    public static function __callStatic($name, $arguments)
    {
        if ($name == 'log') {
            $level = $arguments[0];
            $message = $arguments[1];
            $context = isset($arguments[2]) ? $arguments[2] : [];
            self::get()->{$name}($level, $message, $context);
        } else {
            $context = isset($arguments[1]) ? $arguments[1] : [];
            self::get()->{$name}($arguments[0], $context);
        }
    }

    public static function get()
    {
        return ApplicationContext::getContainer()->get(LoggerFactory::class)->get('app', 'ws');
    }
}
